require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
// var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
var vm = new Vue({
    el:"#resumePreview",
    data:{
        type:"",
        name:"",
        loadFlag:false,
        list:{
            loginUid:"",
            resumeId:""
        },
        // isScreen:"",
        preview:{}
    },
    mounted:function(){
        this.searchObject = this.getQueryStringArgs();
        this.list.resumeId=this.searchObject&&this.searchObject.resumeId;
        this.list.loginUid=this.searchObject&&this.searchObject.loginUid;
        this.type=this.searchObject&&this.searchObject.type;
        if(this.type==1){
            this.name="简历预览"
        }else{
            this.name="简历详情"
        }
        this.myResumePreview();
    },
    methods:{
        //后退
        getBack:function(){
            history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //简历预览
        myResumePreview:function(){
            var that=this;
            this.ajax({url:"/happyi/myResumePreview",data:that.list,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.preview=b.json.data;

                }else{
                    vm.$refs.prompt.toast("获取信息失败！");
                }
            });

        },
        //简历不符
        notGoodResume:function(){
            var that=this;
            var data=that.list;
            data.recruitId=that.preview.functions;
            // data.recruitId="168392e24fc44422ad524f597923c0d0";
            this.ajax({url:"/happyi/notGoodResume",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0){
                    that.preview.recruitState=3;
                }else{
                    vm.$refs.prompt.toast("操作失败！");
                }
            });

        },
        //简历收藏
        resumeCollection:function(){
            var that=this;
            var data=that.list;
            if(that.preview.collectionState==0){
                data.state=1;
            }else{
                data.state=0;
            }
            this.ajax({url:"/happyi/resumeCollection",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0){
                    if(that.preview.collectionState==0){
                        that.preview.collectionState=1;
                    }else{
                        that.preview.collectionState=0;
                    }
                }else{
                    vm.$refs.prompt.toast("操作失败！");
                }
            });

        },
        getNext:function(type){
            // if(type==1){
            //     this.type==type;
            // }else{
            //     location.href="/happyi/previewInfo?resumeId="+this.list.resumeId+"&loginUid="+this.list.loginUid+"&type="+type;
            // }
            location.href="/happyi/previewInfo?resumeId="+this.list.resumeId+"&loginUid="+this.list.loginUid+"&type="+type;
        }
    }
});